//
//  EmployeeDetailViewController.swift
//  HuaYun
//
//  Created by Mac on 2019/3/19.
//  Copyright © 2019 xyxorigation. All rights reserved.
//

import UIKit

class EmployeeDetailViewController: BidDetailViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    
    override func path(for name: String) -> String {
        return EmployeePurchasingApprovalDetail
    }
    
    override func success(for name: String) -> NetSuccess {
        func suc(json: JSON){
            var contents: [Dictionary<String,String?>] = []
            contents.append(["申请人:": json["data"]["details"]["applyPeople"].string])
            contents.append(["联系电话:": json["data"]["details"]["telphone"].string])
            contents.append(["申请日期:": json["data"]["details"]["applyTime"].string])
            contents.append(["申请部门:": json["data"]["details"]["applyDeptname"].string])
            contents.append(["项目名称:": json["data"]["details"]["projectName"].string])
            contents.append(["项目名称:": json["data"]["details"]["projectName"].string])
            contents.append(["外包岗位:": json["data"]["details"]["postname"].string])
            contents.append(["外包岗位:": json["data"]["details"]["postGradeName"].string])
            contents.append(["相关工作年限:": json["data"]["details"]["correlationName"].string])
            let neednum = json["data"]["details"]["needNum"].int ?? 0
            contents.append(["需求人数:": String(neednum)])
            let needcycle = json["data"]["details"]["needCycle"].int ?? 0
            contents.append(["需求周期:": String(needcycle)])
            contents.append(["需求类型:": json["data"]["details"]["demandTypeName"].string])
            contents.append(["学历:": json["data"]["details"]["educationName"].string])
            contents.append(["专业:": json["data"]["details"]["profession"].string])
            contents.append(["必备资格条件:": json["data"]["details"]["mustCondition"].string])
            contents.append(["必备职业资格或资历证书:": json["data"]["details"]["mustOther"].string])
            contents.append(["综合素质能力:": json["data"]["details"]["comprehensiveAbility"].string])
            contents.append(["可优先考虑的条件:": json["data"]["details"]["priorityReason"].string])
            
            contents.append(["备注:": json["data"]["details"]["remarks"].string])
            let files = json["data"]["details"]["attachFiles"].array ?? []
            let purchase = self.ctls[0] as! PurchaseTableViewController
            purchase.source = contents
            purchase.documents = files
            purchase.tableView.reloadData()
            let approvallist = json["data"]["approvalList"].array ?? []
            let approval = self.ctls[1] as! ApprovalRecordListViewController
            approval.source = approvallist
            approval.tableView.reloadData()
        }
        
        return suc
    }
    
    @objc override func approvalAction(button: UIButton){
        let approval = ApprovalSuggestionViewController()
        
        approval.applyId = self.id
        
        approval.netPath = EmployeePurchasingApprovalAction
        
        approval.ifpost = true
        
        approval.businessType = "70"
        
        self.navigationController?.present(vc: approval)
    }

}
